<link href="__PUBLIC__/admin/css/layout.css" rel="stylesheet" type="text/css" />
<link href="__PUBLIC__/js/pagination/pagination.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="__PUBLIC__/js/jquery.js"></script>
<link href="../Public/css/purview.css" rel="stylesheet" type="text/css" />
<div id="container">
  <div class="tab">
    <ul>
      <li><a href="{:U('portal/Channel/admin')}">频道管理</a></li>
      <li><a class="on" href="{:U('portal/Channel/add')}">增加频道</a></li>
      <!--<li><a href="{:U('portal/Purview/index')}">权限管理</a></li>-->
      <li><a href="{:U('portal/Channel/temp')}">模板管理</a></li>
    </ul>
  </div>
  <form name="form1" id="form1" method="post" action="{:U('portal/Channel/doDeal')}">
    <table class="tableborder" width="100%">
      <tr>
        <th colspan="2" class="header">添加频道</th>
      </tr>
      <tr class="label cell">
        <td>说明</td>
        <td>数据</td>
      </tr>
      <tr class="cell">
        <td class="altbg1">频道标题：</td>
        <td class="altbg2"><input class="in_put" style="width:250px" name="title" type="text" id="title" value="{$edit.title}"/></td>
      </tr>
      <tr class="cell">
        <td class="altbg1">频道域名：</td>
        <td class="altbg2"> {:SITE_URL}/
          <input name="domain" type="text" id="domain" value="{$edit.domain}"  class="in_put" style="width:180px" />
          （只允许英文字母/数字/下划线） </td>
      </tr>
      <tr class="cell">
        <td class="altbg1">类型：</td>
        <td class="altbg2"><input name="type" type="radio" value="1" checked="checked" />
          门户
          <input type="radio" name="type" value="2" />
          专题</td>
      </tr>
      <tr class="cell">
        <td class="altbg1">可选模板：</td>
        <td class="altbg2"><select name="temp" class="in_put_01" id="temp">
            <volist name='fileArr' id="vo">
              <option value="{$vo}">{$vo}</option>
            </volist>
          </select></td>
      </tr>
      <tr class="cell">
        <td class="altbg1">分类标签：</td>
        <td class="altbg2"><input class="in_put" style="width:300px"  name="tags" type="text" id="tags" value="{$edit.tags}" /><br />
		<volist name='taglist' id='vo'>
		<span class="tab_adm_a"><a class="pl5" href="javascript:void(0)" onclick="addTag('{$vo.tagname}')">{$vo.tagname}({$vo.tagcount})</a></span>
		</volist>
		</td>
      </tr>
      <tr class="cell">
        <td class="altbg1">状态：</td>
        <td class="altbg2"><label>
            <input name="status" type="radio" value="1" checked="checked" />
            开通
            <input type="radio" name="status" value="0" />
            未开通</label></td>
      </tr>
      <tr>
        <td colspan="2" class="footer"><input type="hidden" name="id" id="id" value="" />
          <input type="button" class="submit" name="button" id="button" value="提交" onclick="checkForm()" /></td>
      </tr>
    </table>
  </form>
</div>
<script type="text/javascript">
  $("#temp").val("default");
function checkForm(){
	var domain = $("#domain").val();
	
	//判断第一字母是否为字母
	var str = /[_a-zA-Z]/;	
	var a = domain.substring(0,1);
	if(!str.test(a))
	{
	     alert("访问链接第一字母必须是字母");
		 return false;
	}
	
	//只允许字母，数字和下划线
	var str = /^[a-zA-Z0-9_]{1,}$/;
	if(!str.test(domain))
	{
	     alert("访问链接只能由字母，数字和下划线组成");
		 return false;
	}
	
	//不能重名
	var url = "{:U('portal/Channel/checkDomain')}";
	$.post(url, {domain:domain,id:0}, function(res){
		if(res==1){
			 alert("访问链接已经存在，请重命名");
			 return false;			
		}else{
			$("#form1").submit();
		}
	});		
} 

function addTag(tagname){
   var tag = $('#tags').val();
   if(tag=='') tag = tagname;
   else        tag = tag+','+tagname;
   $('#tags').val(tag);
} 
</script>
